<?php

namespace app\index\controller;

use think\Controller;

use think\Db;
use think\Session;

class Detail extends Controller
{
    public function index($id)
    {
//        echo 111;die;
        $res4=db('category')->where('pid',0)->field('id,cname')->select();

        $res=db('txt')->where('id',$id)->find();
        $data=db('category')->where('id',$res['cid'])->find();
        $data1=db('category')->where('id',$data['pid'])->find();
//        Session::set('id','4');
        $count = db('chapter')->where('bid',$id)->count('id');
        //
        $list = db('chapter')->where('bid',$id)->order('id','asc')->select();
        // var_dump($list);die;
       // dump($res);die
        return view('detail/index',['data'=>$data,'data1'=>$data1,'res'=>$res,'data4'=>$res4,'list'=>$list,'count' => $count]);
    }


}
